#
# Make file to build the mSQL Database Driver for DBConnect API
# Copyright (c) Johnathan Ingram 2002
#
# dynamic: No .so provided by mSQL
# static:  Build the driver allowing driver to run on machines without 
#          mSQL installed. Statically links msql symbols into driver. (Default)
#
#####################################################################

SHELL = /bin/sh

top_srcdir = ../..
CC = gcc
CXX = g++
CPPFLAGS = 
CFLAGS = -fPIC $(CPPFLAGS) -g -O2 -DLINUX -DDBCONNECTVER='"0.3.5"'
LINKER_FLAGS = 
IFLAGS = -I../base -I/usr/local/msql3/include

SOURCES = msqlConnection.cpp msqlQuery.cpp msqlBindParam.cpp
LIB_OBJS = $(SOURCES:.cpp=.o)
LIB_OBJS += main_so.o

all: 
	cp -f ./dbconndrv-msql-0.3.5.so $(top_srcdir)/lib/drivers
	cd $(top_srcdir)/lib/drivers && ln -sf dbconndrv-msql-0.3.5.so dbconndrv-msql.so && cd -

static: $(LIB_OBJS)
	gcc -shared $(LINKER_FLAGS) \
	-o dbconndrv-msql-0.3.5.so $(LIB_OBJS) \
	/usr/local/msql3/lib/ -ldl -lpthread  \
	-L../dbconnect -ldbconnect-0.3.5

dynamic: static
	@echo "Built the mSQL driver statically as only supported option."

clean:
	rm -f *.o
	rm -f *.so
	rm -f $(top_srcdir)/lib/drivers/dbconndrv-msql-0.3.5.so


main_so.o: main_so.cpp
	$(CXX) -c main_so.cpp $(CFLAGS) $(IFLAGS) -o main_so.o


%.o: %.cpp %.h
	$(CXX) -c $< $(CFLAGS) $(IFLAGS) -o $@


